package com.lintf.nacos;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lin tingfeng
 * @ system Mac
 * @ data 2025/3/20 15:44
 * @ package_name com.lintf
 * @ project_name spring-ai
 * @ desc
 */
@RestController
public class UserController {

//    @Value("${k1:默认值}") // 不支持Nacos配置自动刷新
//    private String k1;

    @NacosValue(value = "${k1:默认值}", autoRefreshed = true) // 支持Nacos配置自动刷新
    private String k1;

    @GetMapping("getConfig")
    public String getConfig() {
        System.out.println("k1=" + k1);
        return k1;
    }

}
